//Linux C plus plus file
/************************************************************************
 *
 *
 *       			FileName:poll_model.cpp
 *
 *         			Author.wzj
 *
 *       			Email:345517039@qq.com
 *
 *      	    		Create:2017-06-22 23:39:11
 *
 *      		    	Description:-
 *
 *
 *************************************************************************/
#include "poll_model.h"

/**
 * @brief 
 */
PollMode::PollMode(){
	
}


/**
 * @brief 
 */
PollMode::~PollMode(){
	
}


/**
 * @brief 
 *
 * @return 
 */
int PollMode::init(){
	this->stopflag = 0;
	this->ioname="poll";
	try {
		ctx.fds = (struct pollfd *)mem.allocateMemFromMempool(sizeof(struct pollfd)*POLL_INIT_SIZE);
		for(int i = 0; i < POLL_INIT_SIZE;i++){
			this->ctx.fds[i].fd = -1;
			this->ctx.fds[i].events =  this->ctx.fds[i].revents = 0;
		}
		this->ctx.nfds = 0;
		this->ctx.timeout = 1;
	}catch(std::bad_alloc){

		return RET::FAIL;
	}
	//网络连接的初始化;
	set.init();
	return RET::SUCCESS;
}



/**
 * @brief 
 *
 * @param fd
 *
 * @return 
 */
int PollMode::addEvent(int fd)
{
	
	
	return RET::SUCCESS;
}



/**
 * @brief 
 *
 * @param arg
 *
 * @return 
 */
int PollMode::addEvent(void *arg){
		
	

	return RET::SUCCESS;
}


/**
 * @brief 
 *
 * @param arg
 *
 * @return 
 */
int PollMode::delEvent(void *arg){
	

	
	return RET::SUCCESS;
}



